<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Tests</title>
    <f:metadata>
        <f:event listener="#{loginBean.verifyUseLogin}" type="preRenderView">
        </f:event>
    </f:metadata>
</h:head>
<h:body>
    <ui:composition template="menutemp.xhtml">
        <h:form id="data">
            <p:growl id="growl" showDetail="true" autoUpdate="true" life="10000" />
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:menuButton value="Bearbeiten" url="neutest.xhtml" icon="ui-icon-document">
                        <p:menuitem id="linkNeu" value="Neuen Test erstellen" url="neutest.xhtml"
                            icon="ui-icon-document" />
                        <p:menuitem id="bearbeiteTest" value="Aufgaben bearbeiten"
                            actionListener="#{testBean.bearbeiteSelected}" icon="ui-icon-document" />
                    </p:menuButton>
                    <p:menuButton value="Delete" icon="ui-icon-trash">
                        <p:menuitem id="deleteAll" value="All" actionListener="#{testsBean.deleteAll}"
                            icon="ui-icon-trash" update="data" />
                        <p:menuitem id="deleteSelected" value="Selected" actionListener="#{testBean.deleteSelected}"
                            icon="ui-icon-trash" update="data" />
                    </p:menuButton>
                </p:toolbarGroup>
            </p:toolbar>
            <p:contextMenu for="dataTable">
                <p:menuitem value="Bearbeiten" update="data" icon="ui-icon-search"
                    actionListener="#{testBean.bearbeiteSelected}" />
                <p:menuitem value="Löschen" update="data" icon="ui-icon-trash"
                    actionListener="#{testBean.deleteSelected}" />
            </p:contextMenu>
            <p:dataTable id="dataTable" var="test" value="#{testBean.tests}" rowKey="#{test.id}"
                selection="#{testBean.selectedTests}" selectionMode="multiple">
                <f:facet name="header">  
                    Test 
                </f:facet>
                <p:column sortBy="#{test.semester}">
                    <f:facet name="header">
                        <h:outputText value="Semester" />
                    </f:facet>
                    <h:outputText value="#{test.semester}" />
                </p:column>
                <p:column sortBy="#{test.fachgebiet}">
                    <f:facet name="header">
                        <h:outputText value="Fachgebiet" />
                    </f:facet>
                    <h:outputText value="#{test.fachgebiet}" />
                </p:column>
                <p:column sortBy="#{test.name}">
                    <f:facet name="header">
                        <h:outputText value="Bezeichnung" />
                    </f:facet>
                    <h:outputText value="#{test.name}" />
                </p:column>
                <p:column sortBy="#{test.datum}">
                    <f:facet name="header">
                        <h:outputText value="Datum" />
                    </f:facet>
                    <h:outputText value="#{test.datum}" />
                </p:column>
                <p:column sortBy="#{test.bearbeiter}">
                    <f:facet name="header">
                        <h:outputText value="Bearbeiter" />
                    </f:facet>
                    <h:outputText value="#{test.bearbeiter}" />
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:composition>


</h:body>
</html>